#!/bin/bash

echo "Obtaining lists from IMDB..."

./get_lists.sh

if [ $? -ne 0 ]; then
    echo "ERROR: Lists could not been obtained!"
    exit 1
fi

echo "Encoding lists to UTF-8..."

./toutf8.sh

if [ $? -ne 0 ]; then
    echo "ERROR: Lists could not been encoded to UTF-8!"
    exit 1
fi

echo "Cleaning people lists..."

./clean_people_lists.sh

if [ $? -ne 0 ]; then
    echo "ERROR: Some problem occured while people lists were being cleaned..."
    exit 1
fi

echo "Cleaning other lists..."

./clean_other_lists.sh

if [ $? -ne 0 ]; then
    echo "ERROR: Some problem occured while others lists were being cleaned..."
    exit 1
fi

for f in `ls *.list.tmp`; do
    mv "$f" "${f/.tmp/}"
done